from appium.webdriver.common.appiumby import AppiumBy as By
from pages.base_page import BasePage


# 定位器
cpllect_locator = (By.ANDROID_UIAUTOMATOR, 'new UiSelector().text("收藏")')
menu_locator=(By.ANDROID_UIAUTOMATOR,'new UiSelector().text("菜单")')
board_title_locator=(By.ID,'com.xiachufang:id/board_title')
add_recipe_locator=(By.ANDROID_UIAUTOMATOR,'new UiSelector().resourceId("com.xiachufang:id/add_recipe").instance(1)')
browse_history_locator=(By.ANDROID_UIAUTOMATOR,'new UiSelector().text("浏览历史")')
cb_selected_locator=(By.ANDROID_UIAUTOMATOR,'new UiSelector().resourceId("com.xiachufang:id/cb_selected").instance(0)')
navigation_right_btn_locator=(By.ANDROID_UIAUTOMATOR,'new UiSelector().resourceId("com.xiachufang:id/navigation_right_btn")')
text_locator=(By.ANDROID_UIAUTOMATOR,'new UiSelector().text("极简·古法｜酱牛肉·卤牛肉·牛腱子｜卡卡爸·不藏私")')
more_locator=(By.ANDROID_UIAUTOMATOR,'new UiSelector().resourceId("com.xiachufang:id/more").instance(2)')
delete_locator=(By.ANDROID_UIAUTOMATOR,'new UiSelector().text("移除")')

navigation_img_view_locator=(By.ANDROID_UIAUTOMATOR,'new UiSelector().resourceId("com.xiachufang:id/navigation_img_view").instance(1)')
et_title_locator=(By.ANDROID_UIAUTOMATOR,'new UiSelector().resourceId("com.xiachufang:id/et_title")')
et_describe_locator=(By.ANDROID_UIAUTOMATOR,'new UiSelector().resourceId("com.xiachufang:id/et_describe")')
tv_right_locator=(By.ANDROID_UIAUTOMATOR,'new UiSelector().resourceId("com.xiachufang:id/tv_right")')
iv_check_box_locator=(By.ANDROID_UIAUTOMATOR,'new UiSelector().resourceId("com.xiachufang:id/iv_check_box")')
tv_right_01_locator=(By.ANDROID_UIAUTOMATOR,'new UiSelector().resourceId("com.xiachufang:id/tv_right")')
board_description_locator=(By.ANDROID_UIAUTOMATOR,'new UiSelector().resourceId("com.xiachufang:id/board_description")')
iv_more_locator=(By.ID,'com.xiachufang:id/iv_more')
item_share_icon_locator=(By.ANDROID_UIAUTOMATOR,'new UiSelector().resourceId("com.xiachufang:id/item_share_icon").instance(6)')
tv_delete_locator=(By.ID,'com.xiachufang:id/tv_delete')
tv_right_02_locator=(By.ID,'com.xiachufang:id/tv_right')


class CpllectMenuPage(BasePage):

    def click_cpllect(self):
        """
        点击收藏
        :return:
        """
        self.find_element(cpllect_locator).click()

    def click_menu(self):
        """
        点击菜单
        :return:
        """
        self.find_element(menu_locator).click()

    def click_board_title(self):
        """
        点击自定义计划
        :return:
        """
        self.find_element(board_title_locator).click()


    def click_add_recipe(self):
        """
        点击添加菜谱
        :return:
        """
        self.find_element(add_recipe_locator).click()

    def click_browse_history(self):
        """
        点击浏览历史
        :return:
        """
        self.find_element(browse_history_locator).click()

    def click_cb_selected(self):
        """
        选中第一个菜谱
        :return:
        """
        self.find_element(cb_selected_locator).click()

    def click_navigation_right_btn(self):
        """
        点击完成
        :return:
        """
        self.find_element(navigation_right_btn_locator).click()

    def get_text(self):
        """
        获取文本
        :return:
        """
        el=self.find_element(text_locator).text
        return el

    def click_more(self):
        """
        点击编辑菜谱
        :return:
        """
        self.find_element(more_locator).click()

    def click_delete(self):
        """
        点击移除
        :return:
        """
        self.find_element(delete_locator).click()

    def navigation_img_view(self):
        """
        点击创建菜单
        :return:
        """
        self.find_element(navigation_img_view_locator).click()

    def input_et_title(self):
        """
        输入标题
        :return:
        """
        self.find_element(et_title_locator).send_keys("酱牛肉")

    def input_et_describe(self):
        """
        输入描述
        :return:
        """
        self.find_element(et_describe_locator).send_keys("这是一大盘酱牛肉")

    def click_tv_right(self):
        """
        点击完成
        :return:
        """
        self.find_element(tv_right_locator).click()

    def click_iv_check_box(self):
        """
        选中第一个菜谱
        :return:
        """
        self.find_element(iv_check_box_locator).click()

    def click_tv_right_01(self):
        """
        点击完成
        :return:
        """
        self.find_element(tv_right_01_locator).click()
    def get_board_description(self):
        """
        获取文本
        :return:
        """
        el=self.find_element(board_description_locator).text
        return el

    def click_iv_more(self):
        """
        点击更多
        :return:
        """
        self.find_element(iv_more_locator).click()
    def click_item_share_icon(self):
        """
        点击编辑菜单
        :return:
        """
        self.find_element(item_share_icon_locator).click()


    def click_tv_delete(self):
        """
        点击删除
        :return:
        """
        self.find_element(tv_delete_locator).click()

    def click_tv_right_02(self):
        """
        点击确认删除
        :return:
        """
        self.find_element(tv_right_02_locator).click()